package com.kuang.lesson03;

import utils.JdbcUtils;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class TestSelect {
    public static void main(String[] args) {
        Connection conn = null;
        PreparedStatement st = null;
        ResultSet rs = null;
        try {
            conn = JdbcUtils.getConnection();
            String sql = "select * from users";
            st = conn.prepareStatement(sql);
            rs = st.executeQuery();
            while (rs.next()){
                System.out.println("id:"+rs.getInt("id"));
                System.out.println("name"+rs.getString("name"));
                System.out.println("password"+rs.getString("password"));
                System.out.println("email"+rs.getString("email"));
                System.out.println("birthday"+rs.getDate("birthday"));
                System.out.println("=======================");
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            JdbcUtils.release(conn, st, rs);
        }
    }
}
